/**************************************TRIM IN JAVASCRIPT STARTS FROM HERE************************************************/
// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}


function Trim(str)
{  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
  return str;
}

/************************************************TRIM IN JAVASCRIPT ENDS HERE*******************************************/



// ################################# start##########################
function createformvalidation()
{
	//alert("sadhashdlaskdlask");

var NameVAlidation=/[0-9\*\=\_\>\<\:\@\&\%\?\$\-\/\!\^\(\)\{\}\|\~\`\'\"\;\,\.\+\#\\]/;
//var USERNameVAlidation=/[\*\=\_\>\<\:\@\&\%\?\$\-\/\!\^\(\)\{\}\|\~\`\'\"\;\,\.\+\#\\]/;
var EmailVALIdation=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var PhonEVAlidation=/[a-zA-Z\*\=\_\>\<\:\@\&\%\?\$\/\!\^\(\)\{\}\|\~\`\'\"\;\,\.\\]/;

	if(document.getElementById("payment_method") != null)
	{
	//alert(1111);
		if(document.getElementById("payment_method").value != '')
		{
			
			var str =Trim(document.getElementById("payment_method").value);
			if( str=='')
			{
				document.getElementById("paymentMethodError").innerHTML="<br>Please Dont Give Space In Country Name Field.";
				document.getElementById("paymentMethodError").style.display='';
				document.getElementById("payment_method").ClassName="RedClass";
				document.getElementById("payment_method").value="";
				document.getElementById("payment_method").focus();
				return false;
			}
			else
			{
				document.getElementById("paymentMethodError").innerHTML="";
				document.getElementById("paymentMethodError").style.display='none';
				document.getElementById("payment_method").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("countryError") != null)
			{
				document.getElementById("paymentMethodError").innerHTML="<br>Please Select The Payment Method.";
				document.getElementById("paymentMethodError").style.display='';
				document.getElementById("payment_method").ClassName="RedClass";
				document.getElementById("payment_method").focus();
				return false;
			}
		}
	}
	

	if(document.getElementById("paymentName") != null)
	{
		
		if(document.getElementById("paymentName").value != '')
		{
			
	var str =Trim(document.getElementById("paymentName").value);

			if( str=='')
			{
				document.getElementById("PaymentNameError").innerHTML="<br>Please Dont Give Space In Payment Name Field.";
				document.getElementById("PaymentNameError").style.display='';
				document.getElementById("paymentName").ClassName="RedClass";
				document.getElementById("paymentName").value="";
				document.getElementById("paymentName").focus();
				return false;
			}
			else
			{
				document.getElementById("PaymentNameError").innerHTML="";
				document.getElementById("PaymentNameError").style.display='none';
				document.getElementById("paymentName").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("PaymentNameError") != null)
			{
				document.getElementById("PaymentNameError").innerHTML="<br>Please Type Your Payment Name.";
				document.getElementById("PaymentNameError").style.display='';
				document.getElementById("paymentName").ClassName="RedClass";
				document.getElementById("paymentName").focus();
				return false;
			}
		}
	}

	if(document.getElementById("credit_card_no") != null)
	{
		if(document.getElementById("credit_card_no").value != '')
		{
			if(document.getElementById("credit_card_no").value.search(PhonEVAlidation) >= 0)
			{
				document.getElementById("credit_card_noError").innerHTML="<br>Credit Card Number Can Be Only Numeric";
				document.getElementById("credit_card_noError").style.display='';
				document.getElementById("credit_card_no").ClassName="RedClass";
				document.getElementById("credit_card_no").focus();
				return false;
			}
			if(document.getElementById("credit_card_no").value.length < 15)
			{
				document.getElementById("credit_card_noError").innerHTML="<br>Credit Card Number Should Be Minimum 15 characters.";
				document.getElementById("credit_card_noError").style.display='';
				document.getElementById("credit_card_no").ClassName="RedClass";
				document.getElementById("credit_card_no").focus();
				return false;
			}
			var str =Trim(document.getElementById("credit_card_no").value);
			if( str=='')
			{
				document.getElementById("credit_card_noError").innerHTML="<br>Please Dont Give Space In Credit Card Number Field.";
				document.getElementById("credit_card_noError").style.display='';
				document.getElementById("credit_card_no").ClassName="RedClass";
				document.getElementById("credit_card_no").value="";
				document.getElementById("credit_card_no").focus();
				return false;
			}
			else
			{
				document.getElementById("credit_card_noError").innerHTML="";
				document.getElementById("credit_card_noError").style.display='none';
				document.getElementById("credit_card_no").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("credit_card_noError") != null)
			{
				document.getElementById("credit_card_noError").innerHTML="<br>Please Type Your Credit Card Number.";
				document.getElementById("credit_card_noError").style.display='';
				document.getElementById("credit_card_no").ClassName="RedClass";
				document.getElementById("credit_card_no").focus();
				return false;
			}
		}
	}

	

	//if(isNaN(document.viewCart.quantity.value)==true)



	if(document.getElementById("credit_card_name") != null)
	{
		if(document.getElementById("credit_card_name").value != '')
		{
			if(isNaN(document.getElementById("credit_card_name").value) != true)
			{
				document.getElementById("credit_card_nameError").innerHTML="<br>Your Credit card Name Should Be Only Charecters.";
				document.getElementById("credit_card_nameError").style.display='';
				document.getElementById("credit_card_name").ClassName="RedClass";
				document.getElementById("credit_card_name").focus();
				return false;
			}
			var str =Trim(document.getElementById("credit_card_name").value);
			if( str=='')
			{
				document.getElementById("credit_card_nameError").innerHTML="<br>Please Dont Give Space In Credit card Name Field.";
				document.getElementById("credit_card_nameError").style.display='';
				document.getElementById("credit_card_name").ClassName="RedClass";
				document.getElementById("credit_card_name").value="";
				document.getElementById("credit_card_name").focus();
				return false;
			}
			else
			{
				document.getElementById("credit_card_nameError").innerHTML="";
				document.getElementById("credit_card_nameError").style.display='none';
				document.getElementById("credit_card_name").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("credit_card_nameError") != null)
			{
				document.getElementById("credit_card_nameError").innerHTML="<br>Please Type Your Credit card Name.";
				document.getElementById("credit_card_nameError").style.display='';
				document.getElementById("credit_card_name").ClassName="RedClass";
				document.getElementById("credit_card_name").focus();
				return false;
			}
		}
	}



if(document.getElementById("securityCode") != null)
	{
		if(document.getElementById("securityCode").value != '')
		{
			if(document.getElementById("securityCode").value.search(PhonEVAlidation) >= 0)
			{
				document.getElementById("securityCodeError").innerHTML="<br>Security Code Can Be Only Numeric";
				document.getElementById("securityCodeError").style.display='';
				document.getElementById("securityCode").ClassName="RedClass";
				document.getElementById("securityCode").focus();
				return false;
			}
			if(document.getElementById("securityCode").value.length < 4)
			{
				document.getElementById("securityCodeError").innerHTML="<br>Security Code Should Be 4 characters.";
				document.getElementById("securityCodeError").style.display='';
				document.getElementById("securityCode").ClassName="RedClass";
				document.getElementById("securityCode").focus();
				return false;
			}
			var str =Trim(document.getElementById("securityCode").value);
			if( str=='')
			{
				document.getElementById("securityCodeError").innerHTML="<br>Please Dont Give Space In Security Code Field.";
				document.getElementById("securityCodeError").style.display='';
				document.getElementById("securityCode").ClassName="RedClass";
				document.getElementById("securityCode").value="";
				document.getElementById("securityCode").focus();
				return false;
			}
			else
			{
				document.getElementById("securityCodeError").innerHTML="";
				document.getElementById("securityCodeError").style.display='none';
				document.getElementById("securityCode").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("securityCodeError") != null)
			{
				document.getElementById("securityCodeError").innerHTML="<br>Please Type Your Security Code.";
				document.getElementById("securityCodeError").style.display='';
				document.getElementById("securityCode").ClassName="RedClass";
				document.getElementById("securityCode").focus();
				return false;
			}
		}
	}

	if(document.getElementById("billingAddress") != null)
	{
		if(document.getElementById("billingAddress").value != '')
		{
			
			var str =Trim(document.getElementById("billingAddress").value);
			if( str=='')
			{
				document.getElementById("billingAddressError").innerHTML="<br>Please Dont Give Space In Company Name Field.";
				document.getElementById("billingAddressError").style.display='';
				document.getElementById("billingAddress").ClassName="RedClass";
				document.getElementById("billingAddress").value="";
				document.getElementById("billingAddress").focus();
				return false;
			}
			else
			{
				document.getElementById("billingAddressError").innerHTML="";
				document.getElementById("billingAddressError").style.display='none';
				document.getElementById("billingAddress").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("billingAddressError") != null)
			{
				document.getElementById("billingAddressError").innerHTML="<br>Please Type Your Business Address.";
				document.getElementById("billingAddressError").style.display='';
				document.getElementById("billingAddress").ClassName="RedClass";
				document.getElementById("billingAddress").focus();
				return false;
			}
		}
	}

if(document.getElementById("billingAddress2") != null)
	{
		if(document.getElementById("billingAddress2").value != '')
		{
			
			var str =Trim(document.getElementById("billingAddress2").value);
			if( str=='')
			{
				document.getElementById("billingAddress2Error").innerHTML="<br>Please Dont Give Space In Company Name Field.";
				document.getElementById("billingAddress2Error").style.display='';
				document.getElementById("billingAddress2").ClassName="RedClass";
				document.getElementById("billingAddress2").value="";
				document.getElementById("billingAddress2").focus();
				return false;
			}
			else
			{
				document.getElementById("billingAddress2Error").innerHTML="";
				document.getElementById("billingAddress2Error").style.display='none';
				document.getElementById("billingAddress2").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("billingAddress2Error") != null)
			{
				document.getElementById("billingAddress2Error").innerHTML="<br>Please Type Your Business Address.";
				document.getElementById("billingAddress2Error").style.display='';
				document.getElementById("billingAddress2").ClassName="RedClass";
				document.getElementById("billingAddress2").focus();
				return false;
			}
		}
	}

	if(document.getElementById("city") != null)
	{
//alert(1111);
		if(document.getElementById("city").value != '')
		{
			
			var str =Trim(document.getElementById("city").value);
			if( str=='')
			{
				document.getElementById("cityError").innerHTML="<br>Please Dont Give Space In City Name Field.";
				document.getElementById("cityError").style.display='';
				document.getElementById("city").ClassName="RedClass";
				document.getElementById("city").value="";
				document.getElementById("city").focus();
				return false;
			}
			else
			{
				document.getElementById("cityError").innerHTML="";
				document.getElementById("cityError").style.display='none';
				document.getElementById("city").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("cityError") != null)
			{
				document.getElementById("cityError").innerHTML="<br>Please Type Your City Name.";
				document.getElementById("cityError").style.display='';
				document.getElementById("city").ClassName="RedClass";
				document.getElementById("city").focus();
				return false;
			}
		}
	}

if(document.getElementById("country") != null)
	{
//alert(1111);
		if(document.getElementById("country").value != '')
		{
			
			var str =Trim(document.getElementById("country").value);
			if( str=='')
			{
				document.getElementById("countryError").innerHTML="<br>Please Dont Give Space In Country Name Field.";
				document.getElementById("countryError").style.display='';
				document.getElementById("country").ClassName="RedClass";
				document.getElementById("country").value="";
				document.getElementById("country").focus();
				return false;
			}
			else
			{
				document.getElementById("countryError").innerHTML="";
				document.getElementById("countryError").style.display='none';
				document.getElementById("country").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("countryError") != null)
			{
				document.getElementById("countryError").innerHTML="<br>Please Select Your Country Name.";
				document.getElementById("countryError").style.display='';
				document.getElementById("country").ClassName="RedClass";
				document.getElementById("country").focus();
				return false;
			}
		}
	}

if(document.getElementById("zip") != null)
	{
		if(document.getElementById("zip").value != '')
		{
			
			var str =Trim(document.getElementById("zip").value);
			if( str=='')
			{
				document.getElementById("zipError").innerHTML="<br>Please Dont Give Space In Zip Code Field.";
				document.getElementById("zipError").style.display='';
				document.getElementById("zip").ClassName="RedClass";
				document.getElementById("zip").value="";
				document.getElementById("zip").focus();
				return false;
			}
			else
			{
				document.getElementById("zipError").innerHTML="";
				document.getElementById("zipError").style.display='none';
				document.getElementById("zip").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("zipError") != null)
			{
				document.getElementById("zipError").innerHTML="<br>Please Type Your Zip Code.";
				document.getElementById("zipError").style.display='';
				document.getElementById("zip").ClassName="RedClass";
				document.getElementById("zip").focus();
				return false;
			}
		}
	}
// var abc=document.getElementById("terms").checked;
// 
// 	if(abc!='1')
// 	{
// 		document.getElementById("termsError").innerHTML="<br> You must accept the Terms and Condition to proceed.";
// 		document.getElementById("termsError").style.display='';
// 		document.getElementById("terms").ClassName="RedClass";
// 		return false;
// 	}


return true;
	

}
// ################################# end #############################